home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MSG Graphic Effects 1.0 Source / Circular wipe.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-23  |  3.2 KB  |  119 lines  |  [TEXT/KAHL]

  1. /*******************************************************************************
  2.  * Copyright © 1992-1993 Mark Pilgrim                                          *
  3.  *                                                                             *
  4.  * This file is provided as is, and may be freely distributed unaltered.  This *
  5.  * message must accompany any copy of this file.  This file may be used or     *
  6.  * modified for use for a non-commercial product provided that appropriate     *
  7.  * credit is given to the author named above.                                  *
  8.  * Commercial use of this source code is prohibited.                           *
  9.  ******************************************************************************/
  10.  
  11. #include "msg misc.h"
  12. #include "msg timing.h"
  13.  
  14. #define BlockSize 17
  15. #define CorrectTime 2
  16.  
  17. void CircularWipe(GrafPtr);
  18.  
  19. /* Trace a region from the center to the topleft corner, over <BlockSize> pixels,
  20.    and back to the center.  Fill that in and move the region parameters +BlockSize.
  21.    Repeat for all sides. */
  22.  
  23. void CircularWipe(GrafPtr sourceGrafPtr)
  24. {
  25.     RgnHandle    curregion;
  26.     Rect        source;
  27.     int            cx,cy,gap,lastx,lasty;
  28.     
  29.     cx = MAIN_WINDOW_WIDTH / 2;
  30.     cy = MAIN_WINDOW_HEIGHT / 2;
  31.  
  32.     curregion=NewRgn();
  33.     source.top=source.left=0;
  34.     source.bottom=MAIN_WINDOW_HEIGHT;
  35.     source.right=MAIN_WINDOW_WIDTH;
  36.     
  37.     gap=BlockSize;
  38.     lastx=0;
  39.     do                                            /* top quadrant */
  40.     {
  41.         StartTiming();
  42.         SetEmptyRgn(curregion);
  43.         MoveTo(cx,cy);
  44.         OpenRgn();
  45.             LineTo(lastx,0);
  46.             LineTo(gap,0);
  47.             LineTo(cx,cy);
  48.         CloseRgn(curregion);
  49.         CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  50.             &source, &source, 0, curregion);
  51.         lastx=gap;
  52.         gap+=BlockSize;
  53.         TimeCorrection(CorrectTime);
  54.     }
  55.     while (gap<MAIN_WINDOW_WIDTH+BlockSize);
  56.     
  57.     gap=BlockSize;
  58.     lasty=0;
  59.     do                                            /* right quadrant */
  60.     {
  61.         StartTiming();
  62.         SetEmptyRgn(curregion);
  63.         MoveTo(cx,cy);
  64.         OpenRgn();
  65.             LineTo(MAIN_WINDOW_WIDTH,lasty);
  66.             LineTo(MAIN_WINDOW_WIDTH,gap);
  67.             LineTo(cx,cy);
  68.         CloseRgn(curregion);
  69.         CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  70.             &source, &source, 0, curregion);
  71.         lasty=gap;
  72.         gap+=BlockSize;
  73.         TimeCorrection(CorrectTime);
  74.     }
  75.     while (gap<MAIN_WINDOW_HEIGHT+BlockSize);
  76.     
  77.     lastx=MAIN_WINDOW_WIDTH;
  78.     gap=MAIN_WINDOW_WIDTH-BlockSize;
  79.     do                                            /* bottom quadrant */
  80.     {
  81.         StartTiming();
  82.         SetEmptyRgn(curregion);
  83.         MoveTo(cx,cy);
  84.         OpenRgn();
  85.             LineTo(lastx,MAIN_WINDOW_HEIGHT);
  86.             LineTo(gap,MAIN_WINDOW_HEIGHT);
  87.             LineTo(cx,cy);
  88.         CloseRgn(curregion);
  89.         CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  90.             &source, &source, 0, curregion);
  91.         lastx=gap;
  92.         gap-=BlockSize;
  93.         TimeCorrection(CorrectTime);
  94.     }
  95.     while (gap>-BlockSize);
  96.     
  97.     lasty=MAIN_WINDOW_HEIGHT;
  98.     gap=MAIN_WINDOW_HEIGHT-BlockSize;
  99.     do                                            /* left quadrant */
  100.     {
  101.         StartTiming();
  102.         SetEmptyRgn(curregion);
  103.         MoveTo(cx,cy);
  104.         OpenRgn();
  105.             LineTo(0,lasty);
  106.             LineTo(0,gap);
  107.             LineTo(cx,cy);
  108.         CloseRgn(curregion);
  109.         CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  110.             &source, &source, 0, curregion);
  111.         lastx=gap;
  112.         gap-=BlockSize;
  113.         TimeCorrection(CorrectTime);
  114.     }
  115.     while (gap>-BlockSize);
  116.     
  117.     DisposeRgn(curregion);
  118. }
  119.